#include<iostream>
#include<cstring>
#include<sys/types.h>
#include<sys/stat.h>
#include<assert.h>
#include<fcntl.h>
#include<cstdio>
#include<unistd.h>
//#include<ncurses.h>
#include"comm.hpp"

int main()
{
    
    int wfd=open(fifoname.c_str(),O_WRONLY);
    if(wfd<0)
    {
        std::cerr<<errno<<":"<<strerror(errno)<<std::endl;
        return 1;
    }

    char buffer[NUM];
    std::cout<<"启动成功"<<std::endl<<"请输入(输入q退出)：";

    while (true)
    {
        
        system("stty raw");
        int c=getchar();
        system("stty -raw");
        if(((char)c)=='q') 
        {
            std::cout<<std::endl<<"quit now ";
            break;
        }

   
        size_t n=write(wfd,(char*)&c,sizeof(char));
        assert(n>0);
        (void)n;
    }
    close(wfd);
    unlink(fifoname.c_str());
    return 0;
    
}